package com.bb.blog.web.exception;

import com.bb.blog.web.constant.ServerExceptionEnum;

/**
 * 服务异常
 */
public class ServerException extends RuntimeException {

    private String msg;
    private Integer code;
    private Object data;

    public ServerException(Integer code, String msg) {

        this(code, msg, null);

    }

    public ServerException(Integer code, String msg, Object data) {
        super(msg);
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ServerException(ServerExceptionEnum exceptionEnum) {
        this(exceptionEnum.getCode(), exceptionEnum.getMsg(), exceptionEnum.getData());
    }


    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
